<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateMenuTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('menu', function (Blueprint $table) {
            // 表引擎
            $table->engine = 'MyISAM';
            $table->charset = 'utf8';
            $table->collation = 'utf8_unicode_ci';
            $table->increments('id')->comment('编号id');
            $table->string('menu_name', 20)->unique()->comment('菜单名称');
            $table->integer('pid')->default(0)->comment('菜单父类id');
            $table->string('route', 100)->nullable()->comment('菜单路由');
            $table->string('icon', 50)->nullable()->comment('菜单图标');
            $table->tinyInteger('is_show')->default(0)->comment('是否显示:1、是，0、否');
            $table->integer('sortby')->default(0)->comment('排序，从大到小排序');
            $table->integer('create_time')->default(0)->comment('创建时间');
            $table->integer('update_time')->default(0)->comment('修改时间');
        });
        $db_prefix = env('DB_PREFIX');
        DB::statement("ALTER TABLE {$db_prefix}menu comment '后台菜单表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('menu');
    }
}
